<%@LANGUAGE="JAVASCRIPT" CODEPAGE="1252" %>
<!--#include file="common/connStr-s.asp" -->

<%
function RunCmd(cmdStr) {
	var comObj = Server.CreateObject('ADODB.Command');
	comObj.ActiveConnection = connStr;
	comObj.CommandText = cmdStr;
	comObj.Execute();
	comObj.ActiveConnection.Close();
	delete comObj;
}
function SortOrder(id, priority) {
    if(id == "" || id == 'undefined'){
        return;
    }
    var cmdStr = ""
    var action = Request.Form("action");
    if (action == "album") {
        cmdStr = "UPDATE dbo.PhotoAlbums SET Priority=" + priority + " WHERE AlbumID=" + id;
    } else {
        cmdStr = "UPDATE dbo.Photos SET Priority=" + priority + " WHERE PhotoID=" + id;
    }
	RunCmd(cmdStr);
}
var sortData = new Array();
var s = ""+Request.Form("SortData");
sortData = s.split(",");
for (i = 0; i < sortData.length; i++) {
    SortOrder(sortData[i], i + 1);
}
Response.Write(sortData);
%>